package com.taobao.machinesystem.exception;

import com.taobao.machinesystem.common.Result;
import com.taobao.machinesystem.utilis.ExceptionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@ControllerAdvice
@RestController
public class ExceptionHandlerController {

    @ExceptionHandler(value = Exception.class)
    public Result exception(Exception e){
        log.error("{} 错误抛出",ExceptionUtils.getMessage(e));
        return Result.error().setMessage(e.getMessage());
    }
}
